<?php

namespace App\Http\Controllers\Api;


use App\Models\Page;
use Illuminate\Http\Request;

class PageController extends BaseController
{
    /**
     * @param Request $request
     * @return array
     */
    public function get(Request $request)
    {
        return ['page' => Page::findOrNew($request->input('pageid'))];
    }

    /**
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function batchget(Request $request)
    {
        $query = Page::whereType($request->input('type','page'));
        if ($catid = $request->input('catid')) {
            $items = $query->where('catid', $catid)->get();
        } else {
            $items = $query->get();
        }

        return ajaxReturn(['items' => $items]);
    }
}
